Skip to content

Client sampling and roots capabilities set to None if not implemented #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lorenzocesconetto
Copy link

@lorenzocesconetto lorenzocesconetto commented May 25, 2025

Right now clients always claims to support sampling and roots capabilities, which is inaccurate.
Having this properly set allows servers to fallback to alternative implementations.

Motivation and Context

Servers might rely on the correctness of client capabilities, so clients should inform them accurately.

How Has This Been Tested?

Unit tests

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@lorenzocesconetto
Copy link
Author

@ihrpr I think this is an important PR to make sure the SDK adheres to the protocol.
This enables servers to make decisions based on the client capabilities.
For instance, server won't waste time trying to send a sampling request to a client that has no sampling capabilities.

roots = None
else:
roots = types.RootsCapability(
# TODO: Should this be based on whether we
Copy link
Contributor

@hesreallyhim hesreallyhim May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec says:

When roots change, clients that support listChanged MUST send a notification:

So I guess it would be the former.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree!
This TODO comment was already in the code base, I just kept it...
I only added the if-else structure around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants